#coding:utf-8
#:import kivy kivy
#:set MODE 0

<MainWindow>:
    title: 'MainWindow'
    popup_basic: popup_basic.__self__
    popup_plot: popup_plot.__self__
    popup_error: popup_error.__self__
    BoxLayout:
        id: main_setting
        orientation: 'vertical'
        GridLayout:
            size_hint_y: 7
            cols: 2
            Label:
                text: '计算模式：' + ('定通量燃耗' if mode.active else "定功率燃耗")
                font_name: app.FONT
            Switch:
                id: mode
                on_active: app.Renew_Mode()
            Button:
                text: '打开基础设置'
                font_name: app.FONT
                on_release: app.Open_Basic()
            Button:
                text: '打开画图设置'
                font_name: app.FONT
                on_release: root.popup_plot.open()
            Label:
                text: '中子通量\n（每平方厘米每秒）' if mode.active else "比功率（兆瓦每吨）"
                font_name: app.FONT
            TextInput:
                id: Flux_Power
                multiline: False
            Label:
                text: "运行时间（天）"
                font_name: app.FONT
            TextInput:
                id: Run_Time
                multiline: False
            Label:
                text: "燃耗步长（天）:%d"%DT.value
                font_name: app.FONT
            Slider:
                id: DT
                min: 10 if mode.active else 1
                max: 30
                step: 1
            Label:
                text: "235U含量\n（千克每吨）"
                font_name: app.FONT
            TextInput:
                id: Weight_U_235_
                multiline: False
            Label:
                text: '解析方法'
                font_name: app.FONT
            Switch:
                id: analytical
                active: True
            Label:
                text: '数值方法'
                font_name: app.FONT
            Switch:
                id: numerical
        Button:
            size_hint_y: 1
            text: '展示结果'
            font_name: app.FONT
            on_release: app.Get_Results()
    BoxLayout:
        id: results
        orientation: 'vertical'
    Popup:
        id: popup_basic
        on_parent: if self.parent == root: root.remove_widget(self)
        title: "Basic Settings"
        GridLayout:
            cols: 2
            Label:
                text: "内步长精度"
                font_name: app.FONT
            TextInput:
                id: Accuracy
                multiline: False
            Label:
                text: "234U含量（千克每吨）"
                font_name: app.FONT
            TextInput:
                id: Weight_U_234
                multiline: False
            Label:
                text: "235U含量（千克每吨）"
                font_name: app.FONT
            TextInput:
                id: Weight_U_235
                multiline: False
            Label:
                text: "238U含量（千克每吨）"
                font_name: app.FONT
            TextInput:
                id: Weight_U_238
                multiline: False
            Button:
                text: "保存并返回"
                font_name: app.FONT
                on_release: app.Set_Basic(True)
            Button:
                text: "不保存并返回"
                font_name: app.FONT
                on_release: app.Set_Basic(False)
    Popup:
        id: popup_plot
        on_parent: if self.parent == root: root.remove_widget(self)
        title: "Plot Settings"
        BoxLayout:
            orientation: 'vertical'
            BoxLayout:
                size_hint_y: 10
                orientation: 'vertical'
                id: plot_settings
            BoxLayout:
                size_hint_y: 1
                Button:
                    text: "保存并返回"
                    font_name: app.FONT
                    on_release: app.Set_Plot(True)
                Button:
                    text: "不保存并返回"
                    font_name: app.FONT
                    on_release: app.Set_Plot(False)
    Popup:
        id: popup_error
        on_parent: if self.parent == root: root.remove_widget(self)
        title: "ERROR"
        BoxLayout:
            orientation: 'vertical'
            Label:
                id: error_message
                font_name: app.FONT
            Button:
                text: "确认"
                font_name: app.FONT
                on_release: root.popup_error.dismiss()

<Plot_Setting>:
    Label:
        id: nuclide
        font_name: app.FONT
    TextInput:
        id: Ratio
        multiline: False
    Switch:
        id: Show

<Result>:
    orientation: 'vertical'
    Image:
        id: image
        size_hint_y: 5
    Label:
        id: label
        size_hint_y: 1
        font_name: app.FONT
